package com.ruoyi;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yangxuqi
 * @Date: 2022/11/16/16:59
 * @Description:
 */
public class TestSend {
    public static void main(String[] args) {
        Socket socket = null;
        try {
            socket = new Socket();
            //客户端连接至服务端
            socket.connect(new InetSocketAddress("127.0.0.1",9100));
            //以输出字节流的方式将本地数据输出至socket中
            OutputStream outputStream = socket.getOutputStream();
            //要发送的字符串信息
            String str = "{\n" +
                    "\t\t\"userId\": \"402835d47ac1bc24017ac708591d001e\",\n" +
                    "\t\t\"orgId\": \"ff8080813897eca20138999b1af100c0\",\n" +
                    "\t\t\"outOrgId\": null,\n" +
                    "\t\t\"outOrgName\": null,\n" +
                    "\t\t\"userName\": \"xx\",\n" +
                    "\t\t\"sedDeptId\": null,\n" +
                    "\t\t\"deptName\": null,\n" +
                    "\t\t\"firstDeptId\": \"xx\",\n" +
                    "\t\t\"firstDeptName\": \"xxxxxx\",\n" +
                    "\t\t\"idNumber\": \"xxxx\",\n" +
                    "\t\t\"phone\": \"xxxxxxxx\",\n" +
                    "\t\t\"hireDate\": null,\n" +
                    "\t\t\"hireStatus\": \"0\",\n" +
                    "\t\t\"entryTime\": \"2021-07-20\",\n" +
                    "\t\t\"separateDate\": null,\n" +
                    "\t\t\"gender\": \"2\",\n" +
                    "\t\t\"userNumber\": \"14778\",\n" +
                    "\t\t\"address\": \"兰州市城关区\",\n" +
                    "\t\t\"supplementAddress\": null,\n" +
                    "\t\t\"email\": \"xxxxxxxxx@qq.com\",\n" +
                    "\t\t\"state\": \"1\",\n" +
                    "\t\t\"researchCentre\": null\n" +
                    "\t}";
            //将字符串转化成字节流用outputstream进行输出
            outputStream.write(str.getBytes());
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (socket != null) {
                try {
                    socket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

}
